using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.skill
{
[System.Serializable]
public  class SkillDevelop :   cfg.EditorReadWriter 
 {

    public cfg.equip.EWeaponType weaponType ;
     public string weaponName  = "";
     public string name  = "";
     public string icon  = "";
     public int iconRow ;
     public int iconCol ;
     public int skillId ;
     public string skillVideo  = "";
     public int unlockMasteryLv ;
     public cfg.condition.Condition unlockItem ;
     public System.Collections.Generic.List<cfg.skill.SkillLevel> skillLevels  = new System.Collections.Generic.List<cfg.skill.SkillLevel>();
     public System.Collections.Generic.List<cfg.skill.SkillRealm> skillRealms  = new System.Collections.Generic.List<cfg.skill.SkillRealm>();
     


    public const int TYPE_ID = 725005005;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(12);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt((int)weaponType);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(weaponName);  
         os.WriteSize(Tag.STRING | (3 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.STRING | (4 << Tag.TAG_SHIFT));  os.WriteString(icon);  
         os.WriteSize(Tag.INT | (5 << Tag.TAG_SHIFT));  os.WriteInt(iconRow);  
         os.WriteSize(Tag.INT | (6 << Tag.TAG_SHIFT));  os.WriteInt(iconCol);  
         os.WriteSize(Tag.INT | (7 << Tag.TAG_SHIFT));  os.WriteInt(skillId);  
         os.WriteSize(Tag.STRING | (8 << Tag.TAG_SHIFT));  os.WriteString(skillVideo);  
         os.WriteSize(Tag.INT | (9 << Tag.TAG_SHIFT));  os.WriteInt(unlockMasteryLv);  
         os.WriteSize(Tag.BEAN | (10 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_Condition(unlockItem,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (11 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_skill_SkillLevel(skillLevels,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (12 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_skill_SkillRealm(skillRealms,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   weaponType = (cfg.equip.EWeaponType)(os.ReadInt()); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   weaponName = os.ReadString(); break;  
             case (Tag.STRING | (3 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.STRING | (4 << Tag.TAG_SHIFT)):   icon = os.ReadString(); break;  
             case (Tag.INT | (5 << Tag.TAG_SHIFT)):   iconRow = os.ReadInt(); break;  
             case (Tag.INT | (6 << Tag.TAG_SHIFT)):   iconCol = os.ReadInt(); break;  
             case (Tag.INT | (7 << Tag.TAG_SHIFT)):   skillId = os.ReadInt(); break;  
             case (Tag.STRING | (8 << Tag.TAG_SHIFT)):   skillVideo = os.ReadString(); break;  
             case (Tag.INT | (9 << Tag.TAG_SHIFT)):   unlockMasteryLv = os.ReadInt(); break;  
             case (Tag.BEAN | (10 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); unlockItem = cfg.Extensions.unmarshal_compatible_cfg_condition_Condition(os); os = _oldOs; break; }   
             case (Tag.LIST | (11 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); skillLevels = cfg.Extensions.unmarshal_compatible_list_cfg_skill_SkillLevel(os); os = _oldOs; break; }   
             case (Tag.LIST | (12 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); skillRealms = cfg.Extensions.unmarshal_compatible_list_cfg_skill_SkillRealm(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "SkillDevelop");
        ele.WriteStartElement("weaponType"); ele.WriteAttributeString("id", "1"); ele.WriteEnum(weaponType); ele.WriteEndElement();
         ele.WriteStartElement("weaponName"); ele.WriteAttributeString("id", "2"); ele.WriteString2(weaponName); ele.WriteEndElement();
         ele.WriteStartElement("name"); ele.WriteAttributeString("id", "3"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("icon"); ele.WriteAttributeString("id", "4"); ele.WriteString2(icon); ele.WriteEndElement();
         ele.WriteStartElement("iconRow"); ele.WriteAttributeString("id", "5"); ele.WriteInt(iconRow); ele.WriteEndElement();
         ele.WriteStartElement("iconCol"); ele.WriteAttributeString("id", "6"); ele.WriteInt(iconCol); ele.WriteEndElement();
         ele.WriteStartElement("skillId"); ele.WriteAttributeString("id", "7"); ele.WriteInt(skillId); ele.WriteEndElement();
         ele.WriteStartElement("skillVideo"); ele.WriteAttributeString("id", "8"); ele.WriteString2(skillVideo); ele.WriteEndElement();
         ele.WriteStartElement("unlockMasteryLv"); ele.WriteAttributeString("id", "9"); ele.WriteInt(unlockMasteryLv); ele.WriteEndElement();
         ele.WriteStartElement("unlockItem"); ele.WriteAttributeString("id", "10"); cfg.Extensions.xml_marshal_cfg_condition_Condition(unlockItem,ele); ele.WriteEndElement();
         ele.WriteStartElement("skillLevels"); ele.WriteAttributeString("id", "11"); cfg.Extensions.xml_marshal_list_cfg_skill_SkillLevel(skillLevels,ele); ele.WriteEndElement();
         ele.WriteStartElement("skillRealms"); ele.WriteAttributeString("id", "12"); cfg.Extensions.xml_marshal_list_cfg_skill_SkillRealm(skillRealms,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  weaponType = ele.ReadEnum<cfg.equip.EWeaponType>(); break; 
                 case 2:  weaponName = ele.ReadString2(); break; 
                 case 3:  name = ele.ReadString2(); break; 
                 case 4:  icon = ele.ReadString2(); break; 
                 case 5:  iconRow = ele.ReadInt(); break; 
                 case 6:  iconCol = ele.ReadInt(); break; 
                 case 7:  skillId = ele.ReadInt(); break; 
                 case 8:  skillVideo = ele.ReadString2(); break; 
                 case 9:  unlockMasteryLv = ele.ReadInt(); break; 
                 case 10:  unlockItem = cfg.Extensions.xml_unmarshal_cfg_condition_Condition(ele); break; 
                 case 11:  skillLevels = cfg.Extensions.xml_unmarshal_list_cfg_skill_SkillLevel(ele); break; 
                 case 12:  skillRealms = cfg.Extensions.xml_unmarshal_list_cfg_skill_SkillRealm(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "weapon_type":  weaponType = ele.ReadEnum<cfg.equip.EWeaponType>(); break; 
                 case "weapon_name":  weaponName = ele.ReadString2(); break; 
                 case "name":  name = ele.ReadString2(); break; 
                 case "icon":  icon = ele.ReadString2(); break; 
                 case "icon_row":  iconRow = ele.ReadInt(); break; 
                 case "icon_col":  iconCol = ele.ReadInt(); break; 
                 case "skill_id":  skillId = ele.ReadInt(); break; 
                 case "skill_video":  skillVideo = ele.ReadString2(); break; 
                 case "unlock_mastery_lv":  unlockMasteryLv = ele.ReadInt(); break; 
                 case "unlock_item":  unlockItem = cfg.Extensions.xml_unmarshal_cfg_condition_Condition(ele); break; 
                 case "skill_levels":  skillLevels = cfg.Extensions.xml_unmarshal_list_cfg_skill_SkillLevel(ele); break; 
                 case "skill_realms":  skillRealms = cfg.Extensions.xml_unmarshal_list_cfg_skill_SkillRealm(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
